<template>
  <div><van-field
  v-model="keywords"
  center
  clearable
  label=""
  placeholder="请输入小区或地址"
  type="search"
  @input="getList"
>
  <template #button>
    <van-button size="small" plain style="border:0" @click="$router.go(-1)">取消</van-button>
  </template>
</van-field>
<tr v-for="(rows,index) in clist" :key="index">
  <van-cell :value="rows.communityName" @click="transport(rows.communityName,rows.community)"/></tr>
</div>
</template>

<script>
import {
  getList,
  getCityInfo
} from '@/api/area'
export default {
  data () {
    return {
      keywords: '',
      cityid: '',
      clist: []
    }
  },
  methods: {
    async getList () {
      const { body } = await getList(this.keywords, this.cityid)
      this.clist = body
    },
    transport (communityName, community) {
      this.$store.commit('transCommunity', {
        communityName,
        community
      })
      this.$router.go(-1)
    }
  },
  async created () {
    const { body } = await getCityInfo(this.$store.state.currentcity)
    this.cityid = body.value
  }
}
</script>

<style>

</style>
